package com.example.javaee_blog.model;


import com.example.javaee_blog.constants.Constant;
import lombok.Data;

@Data
public class Result {
    private Integer code;
    private String errMsg;
    private Object date;
    public static Result success(Object date){
        Result result = new Result();
        result.setCode(Constant.SUCCESS_CODE);
        result.setDate(date);
        result.setErrMsg("成功");
        return result;
    }

    public static Result fail(String message){
        Result result = new Result();
        result.setCode(Constant.FAIL_CODE);
        result.setDate(null);
        result.setErrMsg(message);
        return result;
    }

    public static Result fail(String message, Object date){
        Result result = new Result();
        result.setCode(Constant.FAIL_CODE);
        result.setDate(date);
        result.setErrMsg(message);
        return result;
    }

    public static Result unLogin(String message){
        Result result = new Result();
        result.setErrMsg(message);
        result.setCode(Constant.UNLOGIN_CODE);
        result.setDate(null);
        return result;
    }
}
